from os.path import join
import platform
import numpy as np
import os

def path_div_separator():
    if (platform.system() == 'Windows'):
        return '\\'
    elif (platform.system() == 'Linux'):
        return '/'
    else:
        return '/'

# path: dataset_path
def get_file_list(path, use_val):
    val_file_name = ['birmingham_block_1',
                     'birmingham_block_5',
                     'cambridge_block_10',
                     'cambridge_block_7']

    train_files = [join(path, 'train', i) for i in os.listdir(join(path, 'train'))]
    test_files = [join(path, 'test', i) for i in os.listdir(join(path, 'test'))]
    val_files = []

    #TODO remove valfiles in trian or not

    if use_val:
        for file in train_files:
            file_name = file.split(path_div_separator())[-1][:-4]
            if file_name in val_file_name:
                val_files += [file]
                train_files.remove(file)

    return np.sort(train_files), np.sort(val_files), np.sort(test_files)

    # all_files = np.sort(np.hstack((train_files, test_files)))

    # self.all_files = np.sort(glob.glob(join(self.path, 'original_block_ply', '*.ply')))

    # self.val_file_name = ['birmingham_block_1',
    #                       'birmingham_block_5',
    #                       'cambridge_block_10',
    #                       'cambridge_block_7']
    # self.test_file_name = ['birmingham_block_2', 'birmingham_block_8',
    #                        'cambridge_block_15', 'cambridge_block_22',
    #                        'cambridge_block_16', 'cambridge_block_27']
